package hospital.utils;

import hospital.helper.JwtHelper;

import javax.servlet.http.HttpServletRequest;

/**
 * @author
 * @description:
 */
public class AuthContextHolder {

    /**
     * @Author yang
     * @Description //TODO 从token中获取到用户id
     * @Param
     * @return
     **/
    public static Long getUserId(HttpServletRequest request){
        //从header中获取token
        String token = request.getHeader("token");
        //JwtHelper获取id
        Long userId = JwtHelper.getUserId(token);
        return  userId;
    }
    /**
     * @Author yang
     * @Description //TODO 从token中获取到用户name
     * @Param
     * @return
     **/
    public static String getUserName(HttpServletRequest request){
        //从header中获取token
        String token = request.getHeader("token");
        //JwtHelper获取id
        String name = JwtHelper.getUserName(token);
        return  name;
    }
}
